package cn.zhenglincheng;

import cn.teahouse.AbdoSoftHttpClient;

import java.util.Map;

public class App {

    //初始化客户端端参数
    static final String xqdh = "1243";//小区编号
    static final String flag = "0";//数据加密方式,0 ,表示协议内容为json明文， 1-协议内容为标准base64,2-散列base64,3-DES
    static final String http = "http://w.abdosoft.cn/apiout/apiapioutAction.do?go"; //服务端地址
    static final String qmzfc = "v10dWzwfyuJA59VUOd3CDS8B66AFJzL3mpiHQN99cmxq6kAfWvFIcooyLdJpjD0uwqK2Tfuugex9s1R9pIHYQQG1zsigk1e2AneXn0GRePry4sh92W0f1RPrNADKSih3gdF3Thyzn294x8GQ1rQjrYQA136BPZM7x1hz4v0GiI2qhf303OcpoHHF7BnGdsrzf22DDp8oIXELBmI1wmP2FO0OaG6KMKTsIV8RdwkIgFHeOgJ5iJPPvGlUpkCx2KPZ"; //签名字符串
    static final int timeout = 60000;//请求超时时间，60秒

    static String oper = "18650800036";
    static String user = "18650800036";

    public static void main(String[] args) {

        AbdoSoftHttpClient client = new AbdoSoftHttpClient(oper, user, xqdh, flag, http, qmzfc, timeout);

        //取令牌
        System.out.println("取令牌");
        client.getToken("123456", "8888", "http://127.0.0.1:8080/EACHA/back.jsp");

        //读取用户门禁
        System.out.println("分页读取用户门径");
        System.out.println(client.getUserLockStatus(1,30));

        //读取门禁状态
        System.out.println("读取门禁");
        System.out.println(client.getLockStatus("eachalock42AF023338335330"));

        //开启门禁
        System.out.println("开启门禁");
        System.out.println(client.openLock("eachalock42AF023338335330", "1243-M1707251552162J4604"));
        //生成开门密码
        Map<String,String> data = client.createLockPassword("eachalock42AF023338335330",
                3,
                1,
                "12222222222222",
                "张三",
                "XXX公司");
        System.out.println(data);

        //取消一个密码授权
        System.out.println("取消门禁");
        System.out.println(client.cacelLockPassword("eachalock42AF023338335330",data.get("mm")));
    }
}
